package com.ogilvy.cms.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.ogilvy.cms.bean.CmsPage;
import com.ogilvy.cms.dao.CmsPageCommentDao;
import com.ogilvy.frame.hibernate.BaseDaoImpl;

@Repository
public class CmsPageCommentDaoImpl extends BaseDaoImpl<CmsPage> implements
		CmsPageCommentDao {

	public List<CmsPage> selectByCmtIdParentId(Map<String, String> screenMap) {
		StringBuffer hql = new StringBuffer();
		hql.append("from com.ogilvy.cms.bean.CmsPage cp where ");
		hql.append("cp.cmpCmtId=" + screenMap.get("cmpCmtId"));
		hql.append(" and cp.parentCmpId=" + screenMap.get("parentCmpId"));
		// 建立查询语句
		Query query = getSession().createQuery(hql.toString());
		List<CmsPage> list = query.list();
		if (list == null) {
			list = new ArrayList<CmsPage>();
		}
		return list;
	}

}
